<?php
class classTopMenu{
    public function getTopMenu(){
        $_URL 	= new classURL();
        
        $result = '<div id="TopMenu">';
        
        $result.= '
            <dl>			
                <dt onmouseover="javascript:montreTopMenu(\'sTopMenu1\');montre();">'._i18n_topmenu_TOOLS_.'</dt>
                <dd id="sTopMenu1" onmouseover="javascript:montreTopMenu(\'sTopMenu1\');montre();" onmouseout="javascript:montreTopMenu();">
                    <ul>
                        <li><a href="'._URL_INACTIVE_ADDR_.'" onclick="classSimpleMessage();">'._i18n_topmenu_SEND_MESSAGE_.'</a></li>
                        <li><a href="'._URL_INACTIVE_ADDR_.'" onclick="classPhotoAlbum();">'._i18n_topmenu_SHOW_IMAGE_VIEWER_.'</a></li>
                        <li><a href="'._URL_INACTIVE_ADDR_.'" onclick="classProductSearch();">'._i18n_topmenu_SEARCH_.'</a></li>
                        <li>
                            <a href="'.$_URL->SetURL('','name'._URL_VAL_DELIMITER_.(-1)._URL_VAL_DELIMITER_.'0'._URL_VAL_DELIMITER_.'0', '').'"
						>
							'._i18n_topmenu_ACTIONS_.'
						</a>
                        </li>
                        <li>
                            <a href="'.$_URL->SetURL('','name'._URL_VAL_DELIMITER_.(-2)._URL_VAL_DELIMITER_.'0'._URL_VAL_DELIMITER_.'0', '').'"
						>
							'._i18n_topmenu_NEWS_.'
						</a>
                        </li>
                        <li>
                            <a href="'.$_URL->SetURL('','name'._URL_VAL_DELIMITER_.(-3)._URL_VAL_DELIMITER_.'0'._URL_VAL_DELIMITER_.'0', '').'"
						>
							'._i18n_topmenu_SALE_.'
						</a>
                        </li>
                    </ul>
                </dd>
            </dl>            
        ';
        
        //making news feeds
        $result.= '
                <dl>	
                   <dt onmouseover="javascript:montreTopMenu(\'sTopMenu2\');montre();">'._i18n_topmenu_NEWS_.'</dt>
                   <dd id="sTopMenu2" onmouseover="javascript:montreTopMenu(\'sTopMenu2\');montre();" onmouseout="javascript:montreTopMenu();">
                       <ul>
        ';
                                        
        $TMnu_Source=mysql_query("SELECT ID, News_Caption FROM top_menu_news order by News_Show_No");
        $iRowCount = mysql_num_rows($TMnu_Source);
        $iRowIndex = 0;
        while($sql_array_TMnu = mysql_fetch_object($TMnu_Source)){
            $iRowIndex++;
            $result.='<li><a href="'.$_URL->SetURL('1'._URL_VAL_DELIMITER_.$sql_array_TMnu->ID, 'keep_value', '').'">'.$sql_array_TMnu->News_Caption.'</a></li>';
        }
        
        $result.= '
                      </ul>
                   </dd>
                </dl>
        ';
        
        //making users menu items        
        $iNo = 2;	//top categorie's counter
        $TMnu_Source=mysql_query("SELECT * FROM top_menu_top_category order by TC_Show_No");
        while($sql_array_TMnu = mysql_fetch_object($TMnu_Source))
        {
                $iNo++;
                if($sql_array_TMnu->TC_Have_SC!=1){	//ak neexistuje podmenu
                        //zaistenie ID podkategorie be nadpisu
                        $SMnu_Source=mysql_query("SELECT * FROM top_menu_sub_category WHERE TC_ID=".$sql_array_TMnu->ID);
                        $sql_array_SMnu = mysql_fetch_object($SMnu_Source);
                        //vygenerovanie topkategorie s odkazom:
                        $result .= '
                                <dl>
                                    <dt onmouseover="javascript:montreTopMenu();">
                                        <a href="'._URL_INACTIVE_ADDR_.'">
                                            '.$sql_array_TMnu->TC_Caption.'
                                        </a>
                                    </dt>
                                </dl>
                        ';
                }
                else{	//ak existuje podmenu
                        //vygenerovanie topkategorie bez odkazu:
                        $result .= '
                              <dl>			
                                <dt onmouseover="javascript:montreTopMenu(\'sTopMenu'.$iNo.'\');montre();">'.$sql_array_TMnu->TC_Caption.'</dt>
                                <dd id="sTopMenu'.$iNo.'" onmouseover="javascript:montreTopMenu(\'sTopMenu'.$iNo.'\');montre();" onmouseout="javascript:montreTopMenu();">
                                    <ul>
                        ';

                        $SMnu_Source=mysql_query("SELECT * FROM top_menu_sub_category WHERE TC_ID=$sql_array_TMnu->ID order by SC_Show_No");
                        $iRowCount = mysql_num_rows($SMnu_Source);
                        $iRowIndex = 0;
                        while($sql_array_SMnu = mysql_fetch_object($SMnu_Source))
                        {
                            $iRowIndex++;
                            $result .= '
                                    <li>
                                        <a href="'.$_URL->SetURL('2'._URL_VAL_DELIMITER_.$sql_array_SMnu->ID, 'keep_value', '').'">
                                           '.$sql_array_SMnu->SC_Caption.'
                                        </a>
                                    </li>
                            ';
                        }
                        $result.= '
                                  </ul>
                               </dd>
                            </dl>
                        ';
                }
        }
        
        
        
        
        $result.='</div>';
        
        return $result;
    }   
}
?>
